package com.yj.springboottransactional.service;

import com.yj.springboottransactional.mapper.InfoMapper;
import com.yj.springboottransactional.pojo.Info;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class InfoServiceImpl implements InfoService {

    @Autowired
    InfoMapper infoMapper;

    @Override
    @Transactional
    public List<Info> findAll() {
        return infoMapper.selectList(null);
    }

    //todo:事务失效场景1：访问修饰符使用了private
    private List<Info> find(){
        int i = 10 / 0;
        return infoMapper.selectList(null);
    }
}
